package  models.common.entity;

import java.util.Date;

import javax.persistence.Entity;

import play.db.jpa.Model;
/**
 * 商票跟踪表
 *@author xiaojun
 *@version 2017-4-14 下午2:14:35
 */
@Entity
public class t_commercial_paper_record extends Model{
	/**
	 * 构造器
	 */
	public t_commercial_paper_record(){};
	public t_commercial_paper_record(long commer_paper_id,int type,long open_ticket_id,long receive_id,long operator_id,Date paper_datetime){
		this.commer_paper_id = commer_paper_id;
		this.type = t_commercial_paper_record.RecordType.REGISTER.code;
		this.open_ticket_id = open_ticket_id;
		this.receive_id = receive_id; 
		this.operator_id = operator_id;
		this.paper_datetime = paper_datetime;
	};
    

	/**商票id（引用商票）*/
    public long commer_paper_id;

    /**类型（1、开票，2.收票，3背书，4质押，5，提示付款,6解除质押） */
    public int type;

    /**出票人ID */
    public long open_ticket_id;  
    /**接手人id */
    public long receive_id;
    /**付款状态 0 待付款 1 已付款 2 拒付*/
    public int comer_paper_status;
    
    /**操作人id*/
    public long  operator_id;

    
    /**理由*/
    public String remark;

    /**时间 */
    public Date paper_datetime;
    /**获取付款状态*/
    public ComerPaperStatus getPaperStatus() {
    	ComerPaperStatus status = ComerPaperStatus.getEnum(this.comer_paper_status);
		
		return status;
	}
    /**获取操作类型*/
    public RecordType getType() {
    	RecordType status = RecordType.getEnum(this.comer_paper_status);
		
		return status;
	}
    /**
   	 * 商票跟踪表的状态
   	 *
   	 * @description 
   	 *
   	 * @author xiaojun
   	 * @createDate 2017年4月15日
   	 */
   	public enum RecordType {
   		/**类型（0 ，登记1、开票，2.收票，3背书，4质押，5，提示付款） */
   		
   		/** 登记 */
   		REGISTER(0, "登记"),
   		/** 开票 */
   		OUT_INVOICE(1, "开票"),
   		
   		/** 收票*/
   		INVOICE(2, "收票"),
   		/** 背书*/
   		ENDORSER(3, "背书"),
   		 /**质押*/
   		PLEDGE(4, "质押"),
   		 /**提示付款 */
   		PRESENT_PAYMENT(5, "提示付款"),
   		/**解除质押*/
   		REMOVE_PLEDGE(6,"解除质押") 
   		;
   		 
   
   		
   		/** 状态 */
   		public int code;
   		
   		/** 描述 */
   		public String value;
   		
   		
   		
   		
   		private RecordType(int code, String value){
   			this.code = code;
   			this.value = value;
   		}
   		
   		public static RecordType getEnum(int code){
   			RecordType[] bidstatus = RecordType.values();
   			for(RecordType income:bidstatus){
   				if(income.code == code){
   					
   					return income;
   				}
   			}
   			
   			return null;
   		}
   	}
    /**
   	 * 商票跟踪表付款的状态
   	 *
   	 * @description 
   	 *
   	 * @author xiaojun
   	 * @createDate 2017年4月15日
   	 */
   	public enum ComerPaperStatus{
   	  /**付款状态 0 待付款 1 已付款 2 拒付*/
   		
   		
   		/** 待付款 */
   		OBLIGATION(0, "待付款"),
   		
   		/** 已付款*/
   		PAID(1, "已付款"),
   		/** 拒付*/
   		DISHONOUR(2, "拒付");
   		 
   
   		
   		/** 状态 */
   		public int code;
   		
   		/** 描述 */
   		public String value;
   		
   		
   		
   		
   		private ComerPaperStatus(int code, String value){
   			this.code = code;
   			this.value = value;
   		}
   		
   		public static ComerPaperStatus getEnum(int code){
   			ComerPaperStatus[] bidstatus = ComerPaperStatus.values();
   			for(ComerPaperStatus income:bidstatus){
   				if(income.code == code){
   					
   					return income;
   				}
   			}
   			
   			return null;
   		}
   	}
    
}